package String.StringDemo;

import java.util.Scanner;

public class 数字变大写 {
    public static void main(String[] args) {
        // 键盘录入一个数字
        Scanner sc = new Scanner(System.in);
        int money = 0;
        while (true) {
            System.out.println("请输入一个数字");
            money = sc.nextInt();
            if (money >= 0 && money <= 9999999) {
                break;
            } else {
                System.out.println("输入的数字无效");
            }
        }
        // 得到money里的每一位数字
        String bigNumberResult="";

        while (true){
            int ge=money%10;
            money=money/10;
            String bignumber=numberToBignumber(ge);
            bigNumberResult=bignumber+bigNumberResult;
            if(money==0){
                break;
            }
        }
        System.out.println(bigNumberResult);
        // 在前面补零 补齐七位
        int count=7-bigNumberResult.length();

        for (int i=0;i<count;i++){
            bigNumberResult="零"+bigNumberResult;
        }

        String[] danweiarr={"佰","拾","万","仟","佰","拾","元"};
        String result="";

        for (int i = 0; i < danweiarr.length; i++) {
            result+=bigNumberResult.charAt(i)+danweiarr[i];
        }
        System.out.println(result);
    }

    public static String numberToBignumber(int number) {
        String[] arr = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        return arr[number];
    }
}
